package com.struts2.action;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Restrictions;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.struts2.model.Category;
import com.struts2.model.Color;
import com.struts2.model.Customer;
import com.struts2.model.Designer;
import com.struts2.model.Gender;
import com.struts2.model.Invoice;
import com.struts2.model.Invoice_item;
import com.struts2.model.Product_item;
import com.struts2.model.Product_line;
import com.struts2.model.Season;
import com.struts2.model.Size;
import com.struts2.model.Type;
import com.struts2.service.ViewBuyRecordService;

public class ViewBuyRecordAction extends ActionSupport  implements SessionAware {

	/**
	 * 
	 */
private static final long serialVersionUID = 1L;
	
	
	// For SessionAware
	private Map<String, Object> session;

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	private List<Invoice> invoices;

	private Invoice invoice;

	private List<Invoice_item> invoice_items;

	private int id;

	private String mailing_address;
	private String payment_method;
	private String status;
	private Date date;
	private Customer customer;

	public String execute() {
		String username = (String) session.get("customerLogin");
		ViewBuyRecordService as = new ViewBuyRecordService();
		setInvoices(as.getInvoices(username));
		return "1";
	}

	public String edit() {
		ViewBuyRecordService as = new ViewBuyRecordService();
		invoice = as.getInvoice(id);

		invoice_items = as.getInvoiceItems(invoice);
		
		return SUCCESS;
	}


	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	public List<Invoice> getInvoices() {
		return invoices;
	}

	public void setInvoices(List<Invoice> invoices) {
		this.invoices = invoices;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMailing_address() {
		return mailing_address;
	}

	public void setMailing_address(String mailing_address) {
		this.mailing_address = mailing_address;
	}

	public String getPayment_method() {
		return payment_method;
	}

	public void setPayment_method(String payment_method) {
		this.payment_method = payment_method;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Invoice getInvoice() {
		return invoice;
	}

	public void setInvoice(Invoice invoice) {
		this.invoice = invoice;
	}

	public List<Invoice_item> getInvoice_items() {
		return invoice_items;
	}

	public void setInvoice_items(List<Invoice_item> invoice_items) {
		this.invoice_items = invoice_items;
	}

	


	
	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}
